<?php defined('IN_PHPCMS') or exit('Access Denied'); ?><?php include template('phpcms','header'); ?>
<link href="<?php echo SKIN_PATH;?>modal.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="images/js/jqModal.js"></script>
<script language="javascript" type="text/javascript">
$().ready(function() {
  $('#comment').val("我也来说两句！");
});

function reply_clearfield()
{
    if ($('#comment').val() == "我也来说两句！") 
    {
        $('#comment').val("");
    }
document.getElementById('code_img').style.display = 'block';document.getElementById('code_img').src='checkcode.php';
}
function reply_restoration()
{
    if($('#comment').val() == '')
    {
        $('#comment').val("我也来说两句！");
    }
}
function ajaxload(commentid) 
{
    //var title = <?php echo $title;?>; 
    var data = "&commentid="+commentid+"&keyid=<?php echo $keyid;?>&verify=<?php echo $verify;?>" ;
    var url =  "<?php echo $MODULE['comment']['url'];?>?action=ajaxpost";
    $.ajax({
         type: "POST",
         url: url,
         data: data,
         success: function(msg){
            $('#repley_layer').html(msg);
         }
    }); 
}

function voteFor(id)
{
this.id = id;
var url = "comment/?action=vote";
var data = '&id='+id + '&field=support';
$.ajax({
url: url,
data: data,
type: 'post',
success :function (msg){
$('#count_'+ id+'_1').text(msg);
}
});
}
/**
* 反对
**/
function voteAgainst (id )
{
this.id = id;
var url  = "comment/?action=vote";
var data = '&id='+id + '&field=against';
$.ajax({
url: url,
data: data,
type: 'post',
success :function (msg){
$('#count_'+ id +'_0').text(msg);
}
});
}

function checkForm()
{
if($('#comment').val() == '' || $('#comment').val() == "我也来说两句！")
{
alert("内容不能为空");
$('#comment').focus();
return false;
}
    if($('#checkcode').val() == '' )
{
alert("验证码不能为空");
$('#checkcode').focus();
return false;
}
    if ($('#comment').val().length > 1000)
    {
        alert("内容太长，最多 1000 个文字");
        return false;
    } 
    /*if( getcookie('<?php echo $keyid;?>') )
    {
        alert("请不要灌水");
return false;
    }*/
    
    
}
function close() 
{
    $("#repley_layer").html("");
}
</script>

<!--begin main-->
<div id="main">
  <div id="main_l">
    <!--begin 面包屑导航-->
    <div id="position"><a href="">首页</a>评论</div>
    <!--begin 评论主题-->
    <h1><span style="color:#077AC7;">话题：</span><a href="<?php echo $url;?>"><?php echo $title;?></a></h1>
    <!--begin 评论列表-->
    <?php if(is_array($comments['info'])) foreach($comments['info'] AS $comment) { ?>
<div class="commentbox">
      <div class="commenthead"><span class="f_r"><?php echo $comment['addtime'];?> 发表</span><strong><?php echo $comment['ip_area'];?>&nbsp;IP：<?php echo $comment['ip'];?></strong><span><?php echo $comment['url'];?></span></div>
      <div class="content">
<?php echo $comment['content'];?>
  </div>
      <div class="commentfunction">
         <a href="javascript:ajaxload(<?php echo $comment['commentid'];?>);" >回复</a>|<span id="count_<?php echo $comment['commentid'];?>_1">
         <a id="votefor_<?php echo $comment['commentid'];?>" href="javascript:voteFor(<?php echo $comment['commentid'];?>);">支持(<?php echo $comment['support'];?>)</a></span>|<span id="count_<?php echo $comment['commentid'];?>_0">
         <a href="javascript:voteAgainst(<?php echo $comment['commentid'];?>);">反对(<?php echo $comment['against'];?>)</a></span>
      </div>
    </div>
<?php } ?>
 <div id="pages"><?php echo $pages;?></div>
    <!--end 评论列表-->
    <!--begin 发表评论-->
    <div class="commentbox">
      <div class="commenthead">
      <span class="f_r">        
        </span>　
        <strong>用户评论</strong>　
      </div>
      <div class="commenttext">
        <form action="<?php echo $MODULE['comment']['url'];?>?action=addpost" method="post" onSubmit="return checkForm();" >
<input type="hidden" name="keyid" value="<?php echo $keyid;?>"/>
<input type="hidden" name="verify" value="<?php echo $verify;?>"/>
<ul>
          <li>
            <textarea cols="85" rows="8" name="comment" id="comment" onfocus="reply_clearfield()" onblur="reply_restoration()"></textarea>
          </li>         
          <li>
           <?php if($M[enablecheckcode]) { ?>
            <span>
            <div style="float:left;">&nbsp;验证码：</div><input name="checkcode" id="checkcode" type="text" size="5"  style="ime-mode:disabled;"><img src="" id="code_img" style="display:none;" onclick="this.src='checkcode.php?'+Math.random()" alt="点击换一张">
            </span>
            <?php } ?>    
            <input name="dosubmit" type="submit" value="提交评论" />
          </li>
  <div class="clear"></div>
        </ul>
        </form>
      </div>
    </div>
    <!--end 发表评论-->
  </div>
  <!--begin 右侧边栏-->
  <div id="main_r">
   <!--begin 广告位-->
  <div>
    <script language="javascript" src="data/js.php?id=5"></script>
  </div>
  <!--end 广告位-->
  
  <h4 class="bdr_t_0">最新文章</h4>
  <div>
<ul class="text_list_1">
        <?php echo tag('phpcms', 'tag_content', "SELECT contentid,catid,typeid,areaid,title,style,thumb,keywords,description,userid,updatetime,inputtime,url FROM `phpcms_content` WHERE  status=99   ORDER BY contentid DESC", 0, 10, array (  'class' => 'url',  'target' => '_blank',  'titlelen' => '46',));?>
      </ul>
  </div>
  <!--end 右侧边栏-->
</div></div>
<!--end　主体-->
<!--begin　尾部-->
<div id="repley_layer">
</div>
<?php include template('phpcms','footer'); ?>
